#include<iostream>
using namespace std;
const int N = 1e4 + 10;
int p[N], d[N];
int n, m;
int find(int x)
{
	if (x != p[x] && p[p[x]] != p[x]) {
		int root = find(p[x]);
		d[x] += d[p[x]];
		p[x] = root;
	}
	return p[x];
}
//int find(int x)
//{
//	if (p[x] == x || p[p[x]] == p[x]) {
//		return p[x];
//	}
//	int r = find(p[x]);
//	d[x] += d[p[x]];
//	p[x] = r;
//	return r;
//}
int find(int x)
{
	if (p[x] == x || p[p[x]] == p[x]) {
		return p[x];
	}
	int root = find(p[x]);
	d[x] += d[p[x]];
	p[x] = root;
	return root;
}
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		p[i] = i;
	}
	while (m--) {
		int t, a, b;
		cin >> t >> a >> b;
		if (t == 1) {
			int pa = find(a);
			int pb = find(b);
			if (pa != pb) {
				d[pa] -= d[pb];
				p[pa] = pb;
			}
		}
		else {
			int pa = find(a);
			d[pa] += b;
		}
	}
	for (int i = 1; i <= n; i++) {
		int k = find(i);
		if (i == k) {
			cout << d[i] << " ";
		}
		else {
			cout << d[i] + d[k] << " ";
		}
	}
	return 0;
}